package com.sbxBase.controller;

import com.sbxBase.service.AppStoreService;
import com.common.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Set;

@RestController
@RequestMapping("/appStoreCommon")
@Api(tags = "个人appStore管理")
public class AppStoreCommonController {
    @Resource
    private AppStoreService appStoreService;


    @PostMapping
    @ApiOperation("用户添加app")
    public Result saveUserApp(@RequestBody Set<String> appIds) {
        appStoreService.saveUserApp(appIds);
        return Result.success();
    }

    @ApiOperation("用户取消使用app")
    @DeleteMapping
    public Result deleteUserAppById(@RequestParam("appIds") Set<String> appIds) {
        appStoreService.deleteUserAppById(appIds);
        return Result.success();
    }

    @GetMapping
    @ApiOperation("分页查询用户app")
    public Result getUserAppPage(@ApiParam(value = "起始页", defaultValue = "1") @RequestParam(defaultValue = "1") Integer pageIndex,
                                 @ApiParam(value = "每页", defaultValue = "10") @RequestParam(defaultValue = "10") Integer pageSize) {

        return Result.page(appStoreService.getUserAppPage(pageIndex, pageSize));
    }

}
